package com.eas.web.common.chart;

import java.util.LinkedList;
import java.util.List;

import org.apache.commons.lang.StringUtils;

public class PieChart {

    private String type = "pie";

    private String titleText;

    private List<PieValueNode> values;

    public PieChart() {
        this.values = new LinkedList<PieValueNode>();
    }

    public void setTitleText(String text) {
        this.titleText = text;
    }

    public void addValueNode(PieValueNode valueNode) {
        values.add(valueNode);
    }

    public String renderValues() {
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        sb.append(StringUtils.join(values, ","));
        sb.append("]");
        return sb.toString();
    }

    public String renderTitleText() {
        return titleText;
    }

    public String getType() {
        return type;
    }
}
